/**
 * @name {showToast} 显示提示框
 * **/
export const showToast = (title) => uni.showToast({
    title: title,
    icon: 'none',
    position: 'bottom',
    duration: 2000,
    mask: true,
});

/**
 * @name {showLoading} 显示加载
 * **/
export const showLoading = (title = 'loading...') => uni.showLoading({
    title: title,
    mask: true,
});

//隐藏加载
export const hideLoading = () => {
    return uni.hideLoading();
}

/**
 * @name {showToast} 显示一个模态框
 * **/
export const showModal = (content, title = '温馨提示', showCancel = !![]) => new Promise((resolve, reject) => {
    uni.showModal({
        title: title, content: content, showCancel: showCancel, success: (t) => {
            resolve(t)
        }
    })
})

/**
 * @name {navigateTo} 路由导航
 * **/
export const navigateTo = url => {
    return uni.navigateTo({url: `${url}`,});
}

//停止下拉刷新
export const stopPullDownRefresh = () => {
    return uni.stopPullDownRefresh();
}

/**
 * @name {setNavigationBarTitle} 设置导航栏标题
 * **/
export const setNavigationBarTitle = t => {
    return uni.setNavigationBarTitle({title: `${t}`});
}

/**
 * @name {redirectTo} 关闭当前页面 并跳转到指定页面
 * **/
export const redirectTo = url => {
    return uni.redirectTo({url: `${url}`});
}

/**
 * @name {reLaunch} 关闭所有页面 并到指定页面
 * **/
export const reLaunch = url => {
    return uni.reLaunch({url: `${url}`});
}

/**
 * @name {preloadPage}
 * @param {url} [url] {String} NotNull 预加载页面url
 * **/
export const preloadPage = url => {
    return uni.preloadPage({url: `${url}`});
}

//显示导航条加载
export const showNavigationBarLoading = () => uni.showNavigationBarLoading();

//隐藏导航条加载
export const hideNavigationBarLoading = () => uni.hideNavigationBarLoading();

//浏览器标签是否激活
export const browserTabFocused = () => {
    return !document.hidden;
}

//是否为空
export const isNull = val => {
    return val === undefined || val === null;
}

//是否string
export const isString = val => {
    return typeof val === 'string';
}